import { server } from "@/request/index";
import type {
  attrInfoType,
  attrValueListType,
  attrList3Type,
} from "./category";
//类型体操修改attr
// export type updateAttrType = Partial<Omit<attrInfoType, "attrValueList">>&{attrValueList?:Partial<attrValueListType>[]};
export type IAddOrEditAttrType = Partial<Pick<attrInfoType, "id">> &
  Omit<attrInfoType, "id" | "attrValueList"> & {
    attrValueList: Partial<Omit<attrValueListType, "valueName">> &
      Pick<attrValueListType, "valueName">[];
  };
//基础属性类型
export interface BaseAttrType {
  id: number;
  name: string;
}
export const reqAttrInfoList = (
  category1Id: number,
  category2Id: number,
  category3Id: number
) => {
  return server.get<any, attrInfoType[]>(
    `product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`
  );
};
//attr修改属性
export const reqUpdateAttr = (data: IAddOrEditAttrType) => {
  return server.post<any, IAddOrEditAttrType[]>("/product/saveAttrInfo", data);
};
//删除
export const reqDelAttrItem = (id: number) => {
  return server.delete<any, null>(`product/deleteAttr/${id}`);
};
//3、基础attr属性
export const reqBaseAttr = () => {
  return server.get<any, BaseAttrType[]>(`/product/baseSaleAttrList`);
};
